<?php get_header(); ?>

<script>
  $(document).ready(function(){
    $('.tab-menu ul li:eq(0)').addClass('active');
    
    $('.tab-menu ul li').click(function(){
      var index = $('.tab-menu ul li').index(this);
      $('.tab').css('display', 'none');
      $('#tab'+index).fadeIn('fast');
      
      $('.tab-menu ul li').removeClass('active');
      $(this).addClass('active');
    });
  });
</script>

<div class="content-top"></div>
<div class="content-bottom">
  <div class="wrapper">
    <?php if (function_exists('dimox_breadcrumbs')) dimox_breadcrumbs(); ?>
    <?php
      $posts = get_children('post_parent='.$post->ID.'&post_type=page'); 
      $count = 0;
    ?>
    <div class="tab-wrapper box rounded-equal bg-blue">
      <div class="tab-menu">
        <ul>
          <?php foreach($posts as $post){ ?>
            <li><?php echo $post->post_title; ?></li>
          <?php $count++; } ?>
        </ul>
      </div>
      <div class="tab-content">
        <?php $count = 0;
        foreach($posts as $post){ ?>
          <div id="tab<?php echo $count; ?>" class="tab">
            <h3><?php echo get_field( 'field_title' ); ?></h3>
            
            <?php if (has_post_thumbnail( $post->ID ) ): ?>
              <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
              <div class="tab-image">
                <div class="featured">
                  <img src="<?php echo $image[0]; ?>" />
                </div>
                <?php $attachments = attachments_get_attachments(); ?>
                <?php if($attachments){ ?>
                  <div class="thumbnails">
                    <?php foreach( $attachments as $attachment ) : ?>
                      <div class="thumb">
                        <img src="<?php echo $attachment['location']; ?>" />
                      </div>
                    <?php endforeach; ?>
                  </div>
                <?php } ?>
              </div>
            <?php endif; ?>
            <p><?php echo $post->post_content ?></p>
          </div>
        <?php $count++; } ?>
      </div>
    </div>
  </div>
</div>

<?php get_footer(); ?>
